﻿
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>消息实体</title>
    <link href="../../Scripts/easyUI145/themes/color.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <base target="_self" />
    <script src="../Admin.js"></script>
    <style>
       

    </style>
    <script type="text/javascript">
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        function WinOpen(url, name) {
            window.open(url, name, 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');
            //window.open(url, 'xx');
        }
        /*隐藏与显示.*/
        function ShowHidden(ctrlID) {

            var ctrl = document.getElementById(ctrlID);
            if (ctrl.style.display == "block") {
                ctrl.style.display = 'none';
            } else {
                ctrl.style.display = 'block';
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            InitPage();

        });

        //初始化数据.
        function InitPage() {
            // 设置标签
            $("label[for='RB_Email_1']").html(_GetText(GetQueryString("FK_Event")));
            $("label[for='RB_SMS_1']").html(_GetText(GetQueryString("FK_Event")));

            //初始化 01 02 03
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrFlow");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("PushMsgEntity_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);
            var frmfields = data.FrmFields;
            var nodes = data.Nodes;
            var en = data.PushMsgEntity[0];

            //01.填充下拉
            for (var i = 0, len = frmfields.length; i < len; i++) {
                var f = frmfields[i];
                var oVal = f.KeyOfEn;
                var oText = f.KeyOfEn + "  ; " + f.Name;
                $("#DDL_SMS_Fields").append("<option value='" + oVal + "' >" + oText + "</option>");
                $("#DDL_Email_Fields").append("<option value='" + oVal + "' >" + oText + "</option>");
            }

            //02.节点列表
            for (i = 0, len = nodes.length; i < len; i++) {
                var n = nodes[i];
                $("#SMS_Nodes").append("<label><input id='CB_SMS_" + n.NodeID + "' type='checkbox' name='CB_SMS_" + n.NodeID + "' />" + n.Name + "</label>");
            }

            //03.实体初始化 （如果有）
            if (en.MyPK != "") {
                $("input:radio[name='RB_SMS']").eq(en.SMSPushWay == 6 ? 4 : en.SMSPushWay).attr("checked", true);
                $("#DDL_SMS_Fields").val(en.SMSField);
                $("#TB_SMS").val(en.SMSDoc);
                $("#TB_Email_Title").val(en.MailTitle);
                $("#TB_Email_Doc").val(en.MailDoc);
                var smsnodes = en.SMSNodes;
                var mailnodes = en.MailNodes;
                if (smsnodes != "") {
                    var ns = smsnodes.split(",");
                    for (i = 0, len = ns.length; i < len; i++) {
                        if (ns[i] != "") {
                            document.getElementById("CB_SMS_" + ns[i]).checked = true;
                        }
                    }
                }
                if (mailnodes != "") {
                    var ns = mailnodes.split(",");
                    for (i = 0, len = ns.length; i < len; i++) {
                        if (ns[i] != "") {
                            document.getElementById("CB_Email_" + ns[i]).checked = true;
                        }
                    }
                }

                // 短消息发送形式
                var smsPushModel = en.SMSPushModel;
                if (smsPushModel != "") {
                    var pushModels = smsPushModel.split(",");
                    for (i = 0, len = pushModels.length; i < len; i++) {
                        if (pushModels[i] != "") {
                            document.getElementById("CB_SMSPushModel_" + pushModels[i]).checked = true;
                        }
                    }
                }
            }
            else {
                $("#DDL_SMS_Fields option:first").attr("selected", "selected");
                $("#DDL_Email_Fields option:first").attr("selected", "selected");
            }
        }

        //页面初始化调用
        function _GetText(EventListNode) {

            var ret = {
                "FlowWarning": "发送给所有处理人",
                "FlowOverDue": "发送给所有处理人"
            };
            return ret[EventListNode];

        }

        function Save() {

            //获取短消息发送设置
            var pushModels = document.getElementsByName('CB_SMSPushModel');
            var pushModel = '';
            for (var i = 0; i < pushModels.length; i++) {
                if (pushModels[i].checked)
                    pushModel += pushModels[i].value + ','; //如果选中，将value添加到变量s中
            }
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrFlow");
            handler.AddUrlData();
            handler.AddFormData();
            handler.AddPara("PushModel", pushModel);
            var data = handler.DoMethodReturnString("PushMsg_Save");
            if (data.indexOf('err@') >= 0) {
                alert(data);
                return;
            }

            alert(data);
            Back();
        }

        function Back() {

            var url = '';
            url = 'PushMessage.htm?FK_Node=' + GetQueryString('FK_Node') + '&FK_Flow=' + GetQueryString('FK_Flow') + '&m' + Math.random();
            SetHref(url);
        }
    </script>
</head>
<body onkeypress="Esc();" >
    <form id="cc">
        <div id="bar" class="cs-tr cs-bar">
            <label style="float:left;font-size:13px;font-weight:bolder;padding-top:10px;"> 时限预警、超期 - 消息实体</label>
            <input type="button" name="Btn_Save" value="保存" id="Btn_Save" onclick="Save();" />
            <input type="button" name="Btn_Back" value="返回" id="Btn_Back" onclick="Back();" />
        </div>

        <div style="position:relative;">
            <table style="width: 100%">
                <tr>
                    <td colspan="2">
                        <input id="RB_SMS_0" type="radio" name="RB_SMS" value="0"
                               checked="checked" /><label for="RB_SMS_0">不发送</label>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input id="RB_SMS_1" type="radio" name="RB_SMS" value="1" /><label for="RB_SMS_1">发送当前节点的所有人</label>
                    </td>
                </tr>
                <tr>
                    <td style="width: 200px;">
                        <input id="RB_SMS_2" type="radio" name="RB_SMS" value="2" /><label for="RB_SMS_2">表单上的字段作为接受对象</label>
                    </td>
                    <td>
                        <select name="DDL_SMS_Fields" id="DDL_SMS_Fields" class="frmfields">
                        </select>
                        <ul>
                            <li>字段里必须存储的是人员账号,如果是多个人员账号就用逗号分开. 比如:zhangsan,lisi</li>
                            <li>可以使用隐藏字段作为参数字段.</li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input id="RB_SMS_3" type="radio" name="RB_SMS" value="3" /><label for="RB_SMS_3">其他节点的处理人</label>
                    </td>
                    <td id="SMS_Nodes">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input id="RB_SMS_6" type="radio" name="RB_SMS" value="6" /><label for="RB_SMS_6">开始节点的发起人</label>
                    </td>
                    <td id="SMS_Nodes">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>发送形式</label>
                    </td>
                    <td>
                        <label><input id='CB_SMSPushModel_0' type='checkbox' name='CB_SMSPushModel' value='0' />站内消息</label>
                        <label><input id='CB_SMSPushModel_1' type='checkbox' name='CB_SMSPushModel' value='1' />短信</label>
                        <label><input id='CB_SMSPushModel_4' type='checkbox' name='CB_SMSPushModel' value='2' />钉钉</label>
                        <label><input id='CB_SMSPushModel_3' type='checkbox' name='CB_SMSPushModel' value='3' />微信</label>
                        <label><input id='CB_SMSPushModel_2' type='checkbox' name='CB_SMSPushModel' value='4' />即时通</label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label>邮件标题</label>
                    </td>
                    <td>
                        <input type="text" id="TB_Title" name="TB_Title" style="width:97%;" />
                    </td>
                </tr>

                <tr>
                    <td colspan="2">

                        <a href="javascript:ShowHidden('sms')">消息发送内容模版:</a>
                        <br />
                        <div id="sms" style="display: none; color: Gray">
                            <ul>
                                <li>cc会根据不同的事件设置不同的信息模版。</li>
                                <li>这些模版都是标准的提示，如果您要需要个性化的提示请修改该模版。</li>
                                <li>该参数支持cc表达式。</li>
                                <li>您可以使用@符号来编写您所需要的内容。</li>
                                <li>对于信息提示有两个系统参数分别是{Title}流程标题， {URL} 打开流程的连接。</li>
                                <li>cc在生成消息的时候会根据模版把信息替换下来，发送给用户。</li>
                                <li>最新格式的cc字段表达式为: <font color="red">@+字段名+分号</font> 比如 @QingJiaLeiXing; </li>
                            </ul>
                        </div>

                        <textarea name="TB_SMS" rows="3" cols="20" id="TB_SMS"  style="width: 95%;">
有新工作{{Title}}需要您处理, 发送人:@WebUser.No, @WebUser.Name,打开{Url} .</textarea>
                    </td>
                </tr>
            </table>    
        </div>
    </form>
</body>
</html>
